package com.sugar.psych.assessment.module.business.dal.mysql.userpsychassessmentrecord;

import java.util.*;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sugar.psych.assessment.framework.common.pojo.PageParam;
import com.sugar.psych.assessment.framework.common.pojo.PageResult;
import com.sugar.psych.assessment.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.sugar.psych.assessment.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.psych.assessment.module.business.controller.app.userpsychassessmentrecord.vo.AppUserPsychAssessmentRecordSimpleRespVO;
import com.sugar.psych.assessment.module.business.dal.dataobject.userpsychassessmentrecord.UserPsychAssessmentRecordDO;
import org.apache.ibatis.annotations.Mapper;
import com.sugar.psych.assessment.module.business.controller.admin.userpsychassessmentrecord.vo.*;
import org.apache.ibatis.annotations.Select;

/**
 * 用户心理测评记录 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface UserPsychAssessmentRecordMapper extends BaseMapperX<UserPsychAssessmentRecordDO> {

    default PageResult<UserPsychAssessmentRecordDO> selectPage(UserPsychAssessmentRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserPsychAssessmentRecordDO>()
                .likeIfPresent(UserPsychAssessmentRecordDO::getTitle, reqVO.getTitle())
                .eqIfPresent(UserPsychAssessmentRecordDO::getRiskLevel, reqVO.getRiskLevel())
                .eqIfPresent(UserPsychAssessmentRecordDO::getDone, reqVO.getDone())
                .betweenIfPresent(UserPsychAssessmentRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserPsychAssessmentRecordDO::getId));
    }

    @Select("SELECT * FROM business_user_psych_assessment_record WHERE id = #{param1} AND user_id = #{param2}")
    UserPsychAssessmentRecordDO selectByUserId(Long id, Long loginUserId);

    @Select("select * from business_user_psych_assessment_record where user_id = #{param2}")
    List<AppUserPsychAssessmentRecordSimpleRespVO> selectCustomPage(IPage<AppUserPsychAssessmentRecordSimpleRespVO> page, Long loginUserId);
}